import com.mysql.jdbc.Connection;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DeleteBook {
    public static void main(String[] args) throws SQLException {
        MysqlDataSource dataSource=new MysqlDataSource();
        dataSource.setURL("jdbc:mysql://127.0.0.1:3306/java33?characterEncoding=utf8&useSSL=true");
        dataSource.setUser("root");
        dataSource.setPassword("12345678");

        Connection connection= (Connection) dataSource.getConnection();

        String  deleteSql="delete from booklist where id=?";
        PreparedStatement statement=connection.prepareStatement(deleteSql);
        statement.setInt(1,3);

        int result=statement.executeUpdate();
        System.out.println("执行结果："+result);
        statement.close();
        connection.close();
    }
}
